import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;

/**
 * @author 赵希奥
 * @date 2022/4/20 19:07
 * @gitHub https://github.com/CKXGZXA
 * @gitee https://gitee.com/ckxgzxa
 * @description:
 */
public class Class {
    private ArrayList<Student> students = new ArrayList<>();

    public void addStudent(Student student) {
        students.add(student);
    }

    public void displayStudents() {
        Comparator comp = new MyComparator();
        Collections.sort(students, comp);
        Iterator i = students.iterator();
        while (i.hasNext()) {
            Student s = (Student) i.next();
            System.out.println("姓名: " + s.getsName() + ", 年龄: " + s.getsAge());
        }
    }
}
